package design_pattern.momento.test3;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by WeiDingKuo on 2017/10/27 15:30
 */
public class CareTaker {
    private List<MomentoIF> momentoIFList = new ArrayList<>();

    public void saveMomento(MomentoIF momentoIF) {
        momentoIFList.add(momentoIF);
    }

    public MomentoIF retrieveMomento(int index) {
        return momentoIFList.get(index);
    }

    public void removeDisabledMomento(int index) {
        while (momentoIFList.size() > index) {
            momentoIFList.remove(momentoIFList.size() - 1);
        }
    }

    public List<MomentoIF> getMomentoIFList() {
        return momentoIFList;
    }
}
